<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<meta name="format-detection" content="telephone=no, address=no, email=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="misapplication-tap-highlight" content="no" />
		<meta name="HandheldFriendly" content="true" />
		<title>添加渠道已代理</title>
		<link rel="stylesheet" href="../../css/mui.min.css" type="text/css" charset="utf-8" />
		<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav mui-header">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">添加渠道</h1>
		</header>
		<div class="mui-content" style="padding-left:3.2%;padding-right:3.2%">
			<form class="mui-input-group group-form ease transition" id="group-form">
				<div class="ease transition" id="show-group-form">
					<div style="background:#fff;padding:0.4rem 0.48rem;">
						<p style="color:#f00">已存在经销商信息</p>
						<div id="info">

						</div>
						<div style="margin-top:0.48rem;">
							<p>若信息有误请联系经销商本人修改或联系在乎传媒运营人员。</p>
						</div>

						<div class="mui-input-row" style="background:none;border:1px solid #ddd;">
							<label>产品</label>
							<div class="div-select-container">
								<select id="jd" style="padding-left:5px;"></select>
							</div>
						</div>
					</div>

					<div class="mui-button-row" style="margin-top:0.5rem">
						<button type="button" class="mui-btn mui-btn-primary mui-btn-full" id="nextStep" style="height:44px;background:#f1c40f;color:#fff;border-color:#f1c40f">添加</button>
					</div>

			</form>
			</div>
		</div>

	</body>
	<script src="../../js/resize.js"></script>
	<script src="../../js/mui.min.js"></script>
	<script src="../../js/app.js"></script>
	<script src="../../js/ajaxFun.js"></script>
	<script src="../../js/jxs.js"></script>
	<!--<script type="text/javascript" src="js/update.js"></script>-->
	<script>
		var data = {
			productNo: '',
		};
		var info;
		(function($, doc) {
			$.plusReady(function() {
				plus.nativeUI.closeWaiting();
				Dealers.getProduct(); //获取经销商代理的产品
				var currentView = plus.webview.currentWebview();
				info=currentView.data;
				console.log(info);
				var html = '<div style="margin-top:0.48rem;"> <p>角色：经销商</p> </div> <div> <p>姓名：' + info.name + '</p> </div> <div> <p>公司：' + info.companyName + '</p> </div> <div> <p>电话：' + info.mobile + '</p> </div> <div> <p>地址：' + info.address + '</p> </div>';
				document.getElementById("info").innerHTML = html;
				/*生成经销商信息*/
				/*window.addEventListener('show', function(event) {
					info = event.detail.data; //获得传递的参数
					if(!info) {
						plus.nativeUI.alert('请填写要添加渠道的经销商');
					}
					var html = '<div style="margin-top:0.48rem;"> <p>角色：经销商</p> </div> <div> <p>姓名：' + info.name + '</p> </div> <div> <p>公司：' + info.companyName + '</p> </div> <div> <p>电话：' + info.mobile + '</p> </div> <div> <p>地址：' + info.address + '</p> </div>';
					document.getElementById("info").innerHTML = html;
				});*/
				var nextStep = document.getElementById("nextStep");
				nextStep.addEventListener('tap', addJxs);

			})
		}(mui, document))

		function addJxs() {
			if(!info) {
				plus.nativeUI.alert('请填写要添加渠道的经销商');
				return false;
			}
			nextStep.removeEventListener('tap', addJxs);
			nextStep.style.backgroundColor='#999'; nextStep.style.borderColor='#999';
			data.productNo = document.getElementById("jd").value;
			ajaxFun.postFun(baseUrl + 'dealersController/saveDealer.do', {
				id: info.id,
				productNo: data.productNo
			},'',function(d){		 
				plus.nativeUI.alert(d.msg,function(){
					nextStep.addEventListener('tap', addJxs);
					nextStep.style.backgroundColor='#f1c40f'; nextStep.style.borderColor='#f1c40f';
					openWindow('index.html','main-jxs');
				});
			},function(d){
				plus.nativeUI.alert(d.msg,function(){
						nextStep.addEventListener('tap', addJxs);
						nextStep.style.backgroundColor='#f1c40f'; nextStep.style.borderColor='#f1c40f';
				});
			})
		}
	</script>

</html>